var pre_code = 0;
var menu_logo = null;

/*页面完全加载完后执行*/
window.onload = function () {
    var main_height = $(window).height();
    //alert(main_height);
    var bottom_height = main_height-88-50-20;//横幅，菜单顶部边距,页脚
    $("#center").css({"height": bottom_height});
};

$(window).resize(function () {
    $(".tabs-header, .tabs-wrap ").css("width", "100%");
    $(".tabs-panels, .panel, .panel-body").css("width", "100%");
});

/**
 * 点击菜单后相关操作
 *
 * @param url
 */
function addTab(obj, url, code)
{
    if (code != pre_code)
    {
        if (null != menu_logo)
        {
            changeMenuLogo(menu_logo, pre_code, false);
            $(".menu").removeClass("menu_select");
            $(".menu_title").removeClass("menu_select_title");
        }
        changeMenuLogo(obj.prev(), code, true);
        obj.addClass("menu_select_title");
        obj.parent().addClass("menu_select_div");
        obj.parent().addClass("menu_select");
    }
    document.getElementById("workspace").innerHTML = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
    // 重置窗口大小，消除由于<iframe>中加载的页面过大时纵向滚动条占用了window高度而出现的水平滚动条显现
    $(window).resize();
}

/**
 * 点击后改变相应菜单logo
 *
 * @param obj
 * @param code
 * @param isSelected
 */
function changeMenuLogo(obj, code, isSelected)
{
    var path = "";
    switch (code)
    {
        case 1:
            path = !isSelected ? "../../../images/back/main/org_white.png" : "../../../images/back/main/org_grey.png";
            break;
        case 2:
            path = !isSelected ? "../../../images/back/main/sec_white.png" : "../../../images/back/main/sec_grey.png";
            break;
        case 3:
            path = !isSelected ? "../../../images/back/main/cer_white.png" : "../../../images/back/main/cer_grey.png";
            break;
        case 4:
            path = !isSelected ? "../../../images/back/main/data_white.png" : "../../../images/back/main/data_grey.png";
            break;
        case 5:
            path = !isSelected ? "../../../images/back/main/cer_white.png" : "../../../images/back/main/cer_grey.png";
            break;
        case 6:
            path = !isSelected ? "../../../images/back/main/data_white.png" : "../../../images/back/main/data_grey.png";
            break;
    }
    obj.attr("src", path);
    pre_code = code;
    menu_logo = obj;
}